<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>engine_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_labs_useragent_engine_test.js.html">engine_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2013 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Unit tests for goog.labs.userAgent.engine.
<a name="line17"></a> */
<a name="line18"></a>
<a name="line19"></a>goog.provide(&#39;goog.labs.userAgent.engineTest&#39;);
<a name="line20"></a>
<a name="line21"></a>goog.require(&#39;goog.labs.userAgent.engine&#39;);
<a name="line22"></a>goog.require(&#39;goog.labs.userAgent.testAgents&#39;);
<a name="line23"></a>goog.require(&#39;goog.labs.userAgent.util&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.setTestOnly(&#39;goog.labs.userAgent.engineTest&#39;);
<a name="line27"></a>
<a name="line28"></a>var testAgents = goog.labs.userAgent.testAgents;
<a name="line29"></a>
<a name="line30"></a>function setUp() {
<a name="line31"></a>  goog.labs.userAgent.util.setUserAgent(null);
<a name="line32"></a>}
<a name="line33"></a>
<a name="line34"></a>function assertVersion(version) {
<a name="line35"></a>  assertEquals(version, goog.labs.userAgent.engine.getVersion());
<a name="line36"></a>}
<a name="line37"></a>
<a name="line38"></a>function assertLowAndHighVersions(lowVersion, highVersion) {
<a name="line39"></a>  assertTrue(goog.labs.userAgent.engine.isVersionOrHigher(lowVersion));
<a name="line40"></a>  assertFalse(goog.labs.userAgent.engine.isVersionOrHigher(highVersion));
<a name="line41"></a>}
<a name="line42"></a>
<a name="line43"></a>function testPresto() {
<a name="line44"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.OPERA_LINUX);
<a name="line45"></a>  assertTrue(goog.labs.userAgent.engine.isPresto());
<a name="line46"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line47"></a>  assertVersion(&#39;2.9.168&#39;);
<a name="line48"></a>  assertLowAndHighVersions(&#39;2.9&#39;, &#39;2.10&#39;);
<a name="line49"></a>
<a name="line50"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.OPERA_MAC);
<a name="line51"></a>  assertTrue(goog.labs.userAgent.engine.isPresto());
<a name="line52"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line53"></a>  assertVersion(&#39;2.9.168&#39;);
<a name="line54"></a>  assertLowAndHighVersions(&#39;2.9&#39;, &#39;2.10&#39;);
<a name="line55"></a>}
<a name="line56"></a>
<a name="line57"></a>function testTrident() {
<a name="line58"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.IE_6);
<a name="line59"></a>  assertTrue(goog.labs.userAgent.engine.isTrident());
<a name="line60"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line61"></a>  assertVersion(&#39;&#39;);
<a name="line62"></a>
<a name="line63"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.IE_10);
<a name="line64"></a>  assertTrue(goog.labs.userAgent.engine.isTrident());
<a name="line65"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line66"></a>  assertVersion(&#39;6.0&#39;);
<a name="line67"></a>  assertLowAndHighVersions(&#39;6.0&#39;, &#39;7.0&#39;);
<a name="line68"></a>
<a name="line69"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.IE_8);
<a name="line70"></a>  assertTrue(goog.labs.userAgent.engine.isTrident());
<a name="line71"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line72"></a>  assertVersion(&#39;4.0&#39;);
<a name="line73"></a>  assertLowAndHighVersions(&#39;4.0&#39;, &#39;5.0&#39;);
<a name="line74"></a>
<a name="line75"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.IE_9_COMPATIBILITY);
<a name="line76"></a>  assertTrue(goog.labs.userAgent.engine.isTrident());
<a name="line77"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line78"></a>  assertVersion(&#39;5.0&#39;);
<a name="line79"></a>  assertLowAndHighVersions(&#39;5.0&#39;, &#39;6.0&#39;);
<a name="line80"></a>
<a name="line81"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_11);
<a name="line82"></a>  assertTrue(goog.labs.userAgent.engine.isTrident());
<a name="line83"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line84"></a>  assertVersion(&#39;7.0&#39;);
<a name="line85"></a>  assertLowAndHighVersions(&#39;6.0&#39;, &#39;8.0&#39;);
<a name="line86"></a>}
<a name="line87"></a>
<a name="line88"></a>function testWebKit() {
<a name="line89"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.ANDROID_BROWSER_235);
<a name="line90"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line91"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line92"></a>  assertVersion(&#39;533.1&#39;);
<a name="line93"></a>  assertLowAndHighVersions(&#39;533.0&#39;, &#39;534.0&#39;);
<a name="line94"></a>
<a name="line95"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.ANDROID_BROWSER_403_ALT);
<a name="line96"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line97"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line98"></a>  assertVersion(&#39;534.30&#39;);
<a name="line99"></a>  assertLowAndHighVersions(&#39;533.0&#39;, &#39;535.0&#39;);
<a name="line100"></a>
<a name="line101"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.CHROME_25);
<a name="line102"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line103"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line104"></a>  assertVersion(&#39;535.8&#39;);
<a name="line105"></a>  assertLowAndHighVersions(&#39;535.0&#39;, &#39;536.0&#39;);
<a name="line106"></a>
<a name="line107"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.SAFARI_6);
<a name="line108"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line109"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line110"></a>  assertVersion(&#39;536.25&#39;);
<a name="line111"></a>  assertLowAndHighVersions(&#39;536.0&#39;, &#39;537.0&#39;);
<a name="line112"></a>
<a name="line113"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.SAFARI_IPHONE_6);
<a name="line114"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line115"></a>  assertFalse(goog.labs.userAgent.engine.isGecko());
<a name="line116"></a>  assertVersion(&#39;536.26&#39;);
<a name="line117"></a>  assertLowAndHighVersions(&#39;536.0&#39;, &#39;537.0&#39;);
<a name="line118"></a>}
<a name="line119"></a>
<a name="line120"></a>function testOpera15() {
<a name="line121"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.OPERA_15);
<a name="line122"></a>  assertTrue(goog.labs.userAgent.engine.isWebKit());
<a name="line123"></a>  assertFalse(goog.labs.userAgent.engine.isPresto());
<a name="line124"></a>  assertVersion(&#39;537.36&#39;);
<a name="line125"></a>}
<a name="line126"></a>
<a name="line127"></a>function testGecko() {
<a name="line128"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.FIREFOX_LINUX);
<a name="line129"></a>  assertTrue(goog.labs.userAgent.engine.isGecko());
<a name="line130"></a>  assertVersion(&#39;15.0.1&#39;);
<a name="line131"></a>  assertLowAndHighVersions(&#39;14.0&#39;, &#39;16.0&#39;);
<a name="line132"></a>
<a name="line133"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.FIREFOX_19);
<a name="line134"></a>  assertTrue(goog.labs.userAgent.engine.isGecko());
<a name="line135"></a>  assertVersion(&#39;19.0&#39;);
<a name="line136"></a>  assertLowAndHighVersions(&#39;18.0&#39;, &#39;20.0&#39;);
<a name="line137"></a>
<a name="line138"></a>  goog.labs.userAgent.util.setUserAgent(testAgents.FIREFOX_WINDOWS);
<a name="line139"></a>  assertTrue(goog.labs.userAgent.engine.isGecko());
<a name="line140"></a>  assertVersion(&#39;14.0.1&#39;);
<a name="line141"></a>  assertLowAndHighVersions(&#39;14.0&#39;, &#39;15.0&#39;);
<a name="line142"></a>}
</pre>


</body>
</html>
